/*
 * Copyright (C) 2021 Fastjrun, Inc. All Rights Reserved.
 */
package com.fastjrun.bms.helper;

import com.fastjrun.bms.entity.Book;
import com.fastjrun.bms.entity.LogRecord;
import com.fastjrun.bms.entity.Press;
import com.fastjrun.bms.entity.SysUser;
import com.fastjrun.bms.vo.BookVO;
import com.fastjrun.bms.vo.LogRecordVO;
import com.fastjrun.bms.vo.PressVO;
import com.fastjrun.bms.vo.UserVO;

public class EntityToVOConverter {
  public static final UserVO convert(SysUser sysUser) {
    UserVO userVO = new UserVO();
    userVO.setIsAccountNonExpired(sysUser.getIsAccountNonExpired());
    userVO.setIsCredentialsNonExpired(sysUser.getIsCredentialsNonExpired());
    userVO.setNickName(sysUser.getNickName());
    userVO.setIsEnabled(sysUser.getIsEnabled());
    userVO.setMobile(sysUser.getMobile());
    userVO.setIsAccountNonLocked(sysUser.getIsAccountNonLocked());
    userVO.setId(sysUser.getId());
    userVO.setEmail(sysUser.getEmail());
    userVO.setUsername(sysUser.getUsername());
    return userVO;
  }

  public static final LogRecordVO convert(LogRecord logRecord) {
    LogRecordVO logRecordVO = new LogRecordVO();
    logRecordVO.setId(logRecord.getId());
    logRecordVO.setUserId(logRecord.getUserId());
    logRecordVO.setUsername(logRecord.getUsername());
    logRecordVO.setMobile(logRecord.getMobile());
    logRecordVO.setEmail(logRecord.getEmail());
    logRecordVO.setLoginTime(logRecord.getLoginTime());
    logRecordVO.setLoginIp(logRecord.getLoginIp());
    logRecordVO.setUserAgent(logRecord.getUserAgent());
    return logRecordVO;
  }

  public static final PressVO convert(Press press) {
    PressVO pressVO = new PressVO();
    pressVO.setId(press.getId());
    pressVO.setName(press.getName());
    return pressVO;
  }

  public static final BookVO convert(Book book) {
    BookVO bookVO = new BookVO();
    bookVO.setId(book.getId());
    bookVO.setName(book.getName());
    bookVO.setIsbn(book.getIsbn());
    bookVO.setAuthor(book.getAuthor());
    bookVO.setPrice(book.getPrice());
    bookVO.setPressId(book.getPressId());
    return bookVO;
  }
}
